package com.Dlg 
{
	import com.control.LayerManager;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	/**
	 * ...
	 * @author wen
	 */
	public class BasicDlg 
	{
		public var isInit:Boolean = false;
		
		public var isShow:Boolean = false;
		
		public var view:MovieClip = null;
		
		public function BasicDlg() 
		{
			
		}
		
		/**
		 * 初始化
		 */
		protected function init(mc:MovieClip,callback:Function):void 
		{
			view = mc;
			
			LayerManager.instance.addToLayer(view, LayerManager.DILOG);
			
			view.visible = false;
			
			if (view.closeBtn)
			{
				(view.closeBtn as SimpleButton).addEventListener(MouseEvent.CLICK,onClickHander)
			}
			
			callback();
		}
		
		private function onClickHander(e:MouseEvent):void 
		{
			this.hide();
		}
		
		/**
		 * 隐藏
		 */
		protected function hide():void 
		{
			view.visible = false;
			isShow = false;
		}
		
		protected function showDlg(bgShow:Boolean=false):void 
		{
			var tt:int = view.parent.numChildren;
			view.parent.setChildIndex(view,tt - 1);
			view.visible = true;
			isShow = true;
			
			if (bgShow)
			{
				
			}
		}
	}

}